package com.holly.unit.bpmn.designer.core.strategy;

import com.holly.unit.bpmn.designer.enums.ApprovalTypeEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * 类描述: 创建任务策略工厂类
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/13 9:21
 */
public class CreateTaskStrategyFactory {

    private static final Map<String,CreateTaskStrategy> strategies = new HashMap<>();

    static {
        strategies.put(ApprovalTypeEnum.ASSIGN_USER.fieldName(),new CreateCandidateUsersTaskStrategy());
        strategies.put(ApprovalTypeEnum.ROLE.fieldName(),new CreateCandidateGroupsTaskStrategy());
        strategies.put(ApprovalTypeEnum.INPUT.fieldName(),new CreateInputUsersTaskStrategy());
        strategies.put(ApprovalTypeEnum.SELF.fieldName(),new CreateSelfTaskStrategy());
    }

    public static CreateTaskStrategy getCreateTaskStrategy(String type) {
        if (type == null || type.isEmpty()) {
            throw new IllegalArgumentException("策略枚举类型不能为空!");
        }
        return strategies.get(type);
    }

}
